package arithmetic;

import java.util.Scanner;

/**
 * @author tongchen
 * @create 2023-06-28 16:47
 */
public class ChangeBottle {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        //贪心算法：对于每次移动，只要能确定好一个位置即可
        //创建数组
        int[]a={0,2,1,3,5,4};
        int i = askCount(a);
        System.out.println(i);

    }
    public static int askCount(int[]arr){
        //定义计数器
        int count=0;
        for(int i=1;i<arr.length;++i){
            while(arr[i]!=i){
                swap(arr, i, arr[i]);
                count++;
            }
        }
        return  count;
    }
    public static void swap(int a[],int x,int y){
        int tmp=a[x];
        a[x]=a[y];
        a[y]=tmp;
    }
}
